package com.teemo.equipment.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teemo.equipment.domain.dto.HeroPageDTO;
import com.teemo.equipment.domain.entity.Hero;
import com.teemo.equipment.exception.BizException;
import com.teemo.equipment.service.HeroService;
import com.teemo.equipment.mapper.HeroMapper;
import org.springframework.stereotype.Service;

/**
 * @author 13348
 * @description 针对表【lol_hero(英雄表)】的数据库操作Service实现
 * @createDate 2024-07-19 22:16:13
 */
@Service
public class HeroServiceImpl extends ServiceImpl<HeroMapper, Hero>
        implements HeroService {

    @Override
    public Page<Hero> pageQuery(HeroPageDTO dto) {
        return this.lambdaQuery()
                .like(StrUtil.isNotBlank(dto.getName()), Hero::getName, dto.getName())
                .page(dto.pageParam());
    }

    @Override
    public Hero checkById(Long id) {
        Hero hero = getById(id);
        if (null == hero) {
            BizException.of("英雄不存在");
        }
        return hero;
    }
}




